<?php
    // Send Header
    $xls->setHeader('Reporte_'.date('Y_m_d').'.xls');

    // XLS Data Cell
    $xls->BOF();
    $xls->writeLabel(1,0,"VENETEL");
    $xls->writeLabel(2,0,"Reporte de Contratos : ");

    $xls->writeLabel(4,0,"ID");
    $xls->writeLabel(4,1,"Codigo");
    $xls->writeLabel(4,2,"Gerencia");
    $xls->writeLabel(4,3,"Cliente");


	$x = 5;
	$y = 0;

	foreach ($contratos as $contrato){
    $xls->writeLabel($x, $y++, $contrato['Contrato']['id']);
    $xls->writeLabel($x, $y++, $contrato['Contrato']['codigo']);
    $xls->writeLabel($x, $y++, $contrato['Gerencia']['nm_gerencia'], array('controller' => 'gerencias', 'action' => 'view', $contrato['Gerencia']['id']));
    $xls->writeLabel($x, $y++, $contrato['Cliente']['nm_cliente'], array('controller' => 'clientes', 'action' => 'view', $contrato['Cliente']['id']));
	$x++;
		if($y === 4) {
			$y = 0;
		}
	}

    $xls->EOF();
    exit();
?>